package com.wcx.application.controller;


import com.wcx.application.service.ChatService;
import com.wcx.application.service.CollectionService;
import com.wcx.application.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/collection")
@ResponseBody
public class CollectionController {
    @Autowired
    private CollectionService collectionService;

    @GetMapping("/insert")
    public Result insert(String fromId,String jobId) {
        int  i = collectionService.insert(fromId, jobId);
        if(i!=0){
            return  Result.ok();
        }else{
            return Result.error();
        }
    }

    @GetMapping("/delete")
    public Result delete(String fromId,String jobId) {
        int  i = collectionService.delete(fromId, jobId);
        if(i!=0){
            return  Result.ok();
        }else{
            return Result.error();
        }
    }

    @GetMapping("/search")
    public Result search(String fromId,String jobId) {
        return Result.ok().data("list", collectionService.search(fromId,jobId));
    }

    @GetMapping("/list")
    public Result list(String fromId) {
        return Result.ok().data("list", collectionService.list(fromId));
    }
}